<?php 
return [
	'name' => 'HTML缓存',
	'manager_url' => plugin_url('/html/admin/index'),
	'description' => '用于前端生成HTML缓存，提高浏览效率！',
	'version' => '1.0.0',
	'author' => '谢蕾',
	'weburl' => 'http://www.ebcms.com/',
	'hooks'=>[
		'home_start' => [function(){
			$uri = isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'';
			$key = md5('html_' . $uri);
			if ($html = \mylib\Cache::get($key)) {
				echo \mylib\Response::html($html);
				die();
			}
		}],
		'home_end' => [function(&$html){
			$uri = isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'';
			$key = md5('html_' . $uri);
			$cfg = include __DIR__ . '/cfg.php';
			$cfg = array_merge(['expire'=>3600,'tips'=>''], (Array)$cfg);
			if ($cfg['tips']) {
				$html .= str_replace(['__TIME__', '__EXPIRE__'], [date('Y-m-d H:i:s'), date('Y-m-d H:i:s', time() + $cfg['expire'])], htmlspecialchars_decode($cfg['tips']));
			}
			\mylib\Cache::set($key, $html, $cfg['expire']);
		}]
	],
	'install' => function(){
		return true;
	},
	'uninstall' => function(){
		return true;
	}
];